package edu.gatech.oad.OTConfig;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class ChrisAdamsTest {

private JourneyController testJC;
	
	@Before
	public void setUp() throws Exception{
		testJC = new JourneyController();
	}
	
	@Test
	public void updateDistanceTest(){
		assertEquals("Miles Traveled did not initialize to 0", 0, testJC.getJourney().getMilesTraveled());
		assertEquals("Miles To Next did not initialize correctly", 0, testJC.getTrailNavigator().getMilesToNext());
		assertTrue("Did not correctly detect the Indepence destination", testJC.getTrailNavigator().getIsDestination());
		assertTrue("Did not correctly detect the Indepence store", testJC.getTrailNavigator().getHasStore());
		
		testJC.updateDistance();
		assertEquals("Miles Traveled did not update correctly in first move", 0, testJC.getJourney().getMilesTraveled());
		assertEquals("Miles To Next did not update correctly in first move", 102, testJC.getTrailNavigator().getMilesToNext());
		assertFalse("Incorrectly detected a destination", testJC.getTrailNavigator().getIsDestination());
		assertFalse("Incorrectlly detected a store", testJC.getTrailNavigator().getHasStore());
		
		Wagon.setPace(Pace.Steady);
		testJC.updateDistance();
		assertEquals("Miles Traveled did not update correctly with Steady pace", 15, testJC.getJourney().getMilesTraveled());
		assertEquals("Miles To Next did not update correctly with Steady pace", 87, testJC.getTrailNavigator().getMilesToNext());
		
		Wagon.setPace(Pace.Strenuous);
		testJC.updateDistance();
		assertEquals("Miles Traveled did not update correctly with Strenuous pace", 45, testJC.getJourney().getMilesTraveled());
		assertEquals("Miles To Next did not update correctly with Strenuous pace", 57, testJC.getTrailNavigator().getMilesToNext());
		
		Wagon.setPace(Pace.Grueling);
		testJC.updateDistance();
		assertEquals("Miles Traveled did not update correctly with Grueling pace", 90, testJC.getJourney().getMilesTraveled());
		assertEquals("Miles To Next did not update correctly with Grueling pace", 12, testJC.getTrailNavigator().getMilesToNext());
		
		testJC.updateDistance();
		assertEquals("Miles Traveled did not update correctly when it should have stopped at the end of the trail",
				102, testJC.getJourney().getMilesTraveled());
		assertEquals("Miles To Next did not update correctly when it should have stopped at the end of the trail",
				0, testJC.getTrailNavigator().getMilesToNext());
		
		assertTrue("River was not found at the current Location (Kansas River)", testJC.getTrailNavigator().getIsRiver());
		assertEquals("Location incorrect: Kansas River", "Kansas River", testJC.getTrailNavigator().getLocation());
		assertFalse("Should not be at the end of the journey", testJC.getTrailNavigator().getIsEndOfJourney());
		
		testJC.updateDistance();
		assertFalse("River was found at the current Location (On the way to Big Blue)", testJC.getTrailNavigator().getIsRiver());
		
		assertEquals("Miles Traveled should not have updated after leaving the river", 102, testJC.getJourney().getMilesTraveled());
		assertEquals("Miles To Next incorrect upon leaving the river", 82, testJC.getTrailNavigator().getMilesToNext());
	}

}
